package com.sita.redsun.connector.service.rest;

import com.sita.redsun.connector.server.NodeInfo;
import com.sita.redsun.connector.server.NodeMaping;
import com.sita.redsun.connector.service.common.requestbody.MTInfo;
import com.sita.redsun.connector.service.common.requestbody.Reply;
import com.sita.redsun.connector.service.core.RedSunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * Created by zhebinwang on 2017/4/1.
 */

@RestController
@RequestMapping(value = "v1")

public class SunController {

    @Autowired
    private RedSunService redSunService;


    @RequestMapping(value="mt",
            method = RequestMethod.POST,
            produces = {MediaType.APPLICATION_JSON_VALUE},
            consumes = {MediaType.APPLICATION_JSON_VALUE})

    @ResponseBody
    public Reply createEventWithMessage(
            @RequestBody MTInfo mtInfo

    ){

        redSunService.doMt(mtInfo);

        return new Reply().setData(null).setErrorCode("200");
    }


    @RequestMapping(value="nodeinfo",
            method = RequestMethod.POST,
            produces = {MediaType.APPLICATION_JSON_VALUE},
            consumes = {MediaType.APPLICATION_JSON_VALUE})

    @ResponseBody
    public Reply getNodeInfo(
            //@RequestBody MTInfo mtInfo

    ){

        NodeInfo[] nodeInfos =new NodeInfo[2];


        nodeInfos[0]=new NodeInfo();
        nodeInfos[1]=new NodeInfo();

        nodeInfos[0].setNodeid(0)
                .setNodename("pual")
                .setNodetype(2)//后端oem
                .setLanaddress("10.105.202.51")
                .setInteraddress("115.159.4.234");

        nodeInfos[1].setNodeid(1)
                .setNodename("liping")
                .setNodetype(2)//后端oem
                .setLanaddress("10.105.246.218")
                .setInteraddress("182.254.245.45");

        return new Reply().setData(nodeInfos).setErrorCode("200");
    }




}
